/**
 * 
 */
package parsetree;

import java.util.Collection;
import java.util.concurrent.ExecutionException;

import libraries.Library;
import util.TrieMap;

/**
 * @author Joshua Lockerman
 *
 */
public class DefaultParsingContext implements ParsingContext {
    
    private final TrieMap<ElementFactory> prefixMap;
    
    private DefaultParsingContext(Library lib) throws ExecutionException
    {
        prefixMap = new TrieMap<ElementFactory>();
        Collection<OperatorSpec> specs = lib.loadSpecs();
        for(OperatorSpec spec : specs) {
            prefixMap.put(spec.getLiteral(), spec);
        }
    }
    
    /* (non-Javadoc)
     * @see parsetree.ParsingContext#getPrefixMap()
     */
    @Override
    public TrieMap<ElementFactory> getPrefixMap()
    {
        return prefixMap;
    }
}
